<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	{% load static %}
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
	<title>天天生鲜-商品列表</title>
	<link rel="stylesheet" type="text/css" href="{% static 'css/reset.css' %}">
	<link rel="stylesheet" type="text/css" href="{% static 'css/main.css' %}">
</head>
<body>
	<div class="header_con">
		<div class="header">
			<div class="welcome fl">欢迎来到天天生鲜!</div>
			<div class="fr">
				{% if user.is_authenticated %}
				<div class="login_btn fl">
					欢迎您：<em>{{user.username}}</em>
					<a href="{% url 'user:logout' %}">登出</a>
				</div>
				{% else %}
				<div class="login_btn fl">
					<a href="{% url 'user:login' %}">登录</a>
					<span>|</span>
					<a href="{% url 'user:register' %}">注册</a>
				</div>
				{% endif %}
				<div class="user_link fl">
					<span>|</span>
					<a href="{% url 'goods:index' %}">首页</a>
					<span>|</span>
					<a href="{% url 'user:user' %}">用户中心</a>
					<span>|</span>
					<a href="{% url 'cart:index' %}">我的购物车</a>
					<span>|</span>
					<a href="{% url 'user:order' 1 %}">我的订单</a>
				</div>
			</div>
		</div>		
	</div>

	<div class="search_bar clearfix">
		<a href="index.html" class="logo fl"><img src="images/logo.png"></a>
		<div class="search_con fl">
			<form method="get" action="/search">
				<input type="text" class="input_text fl" name="q" placeholder="搜索商品">
				<input type="submit" class="input_btn fr" name="" value="搜索">
			</form>
		</div>
		<div class="guest_cart fr">
			<a href="{% url 'cart:index' %}" class="cart_name fl">我的购物车</a>
			<div class="goods_count fl">1</div>
		</div>
	</div>

	<div class="navbar_con">
		<div class="navbar clearfix">
			<div class="subnav_con fl">
				<h1>全部商品分类</h1>	
				<span></span>			
				<ul class="subnav">
					{% for type in types %}
					<li><a href="#" class="{{type.logo}}">{{type.name}}</a></li>
					{% endfor %}
				</ul>
			</div>
			<ul class="navlist fl">
				<li><a href="{% url 'goods:index' %}">首页</a></li>
				<li class="interval">|</li>
				<li><a href="">手机生鲜</a></li>
				<li class="interval">|</li>
				<li><a href="">抽奖</a></li>
			</ul>
		</div>
	</div>

	<div class="breadcrumb">
		<a href="#">全部分类</a>
		<span>></span>
		<a href="#">新鲜水果</a>
	</div>

	<div class="main_wrap clearfix">
		<div class="l_wrap fl clearfix">
			<div class="new_goods">
				<h3>新品推荐</h3>
				<ul>
					{% for new in news %}
					<li>
						<a href="{% url 'goods:detail' new.id %}"><img src="{{new.image.url}}"></a>
						<h4><a href="{% url 'goods:detail' new.id %}">{{new.name}}</a></h4>
						<div class="prize">{{new.price}}</div>
					</li>
					{% endfor %}
				</ul>
			</div>
		</div>

		<div class="r_wrap fr clearfix">
			<div class="sort_bar">
				<a href="{% url 'goods:list' type.id page.number %}?sort=default" {% if sort == "default" %}class="active"{% endif %}>默认</a>
				<a href="{% url 'goods:list' type.id page.number %}?sort=price" {% if sort == "price" %}class="active"{% endif %}>价格</a>
				<a href="{% url 'goods:list' type.id page.number %}?sort=hot" {% if sort == "hot" %}class="active"{% endif %}>人气</a>
			</div>

			<ul class="goods_type_list clearfix">
				{% for sku in page %}
				<li>
					<a href="{% url 'goods:detail' sku.id %}"><img src="{{sku.image.url}}"></a>
					<h4><a href="{% url 'goods:detail' sku.id %}">{{sku.name}}</a></h4>
					<div class="operate">
						<span class="prize">{{sku.price}}</span>
						<span class="unit">{{sku.unite}}</span>
						<a href="#" class="add_goods" title="加入购物车"></a>
					</div>
				</li>
				{% endfor %}
			</ul>

			<div class="pagenation">
				{% if page.has_previous %}
				<a href="{% url 'goods:list' type.id page.previous_page_number %}?sort={{sort}}"><上一页</a>
				{% endif %}

				{% for num in sku_pages %}
				{% if num == page.number %}
				<a href="{% url 'goods:list' type.id num %}?sort={{sort}}" class="active">{{num}}</a>
				{% else %}
				<a href="{% url 'goods:list' type.id num %}?sort={{sort}}">{{num}}</a>
				{% endif %}
				{% endfor %}

				{% if page.has_next %}
				<a href="{% url 'goods:list' type.id page.next_page_number%}?sort={{sort}}">下一页></a>
				{% endif %}
			</div>
		</div>
	</div>

	<div class="footer">
		<div class="foot_link">
			<a href="#">关于我们</a>
			<span>|</span>
			<a href="#">联系我们</a>
			<span>|</span>
			<a href="#">招聘人才</a>
			<span>|</span>
			<a href="#">友情链接</a>		
		</div>
		<p>CopyRight © 2016 北京天天生鲜信息技术有限公司 All Rights Reserved</p>
		<p>电话：010-****888    京ICP备*******8号</p>
	</div>
	
</body>
</html>